package com.sdcqjy.mylibrary.widget;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * 描述：
 * Created by rookieCi on 2017/9/21.
 */
public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
    public SpacesItemDecoration(int space, boolean onOff[]) {
        this.space = space;
        if (onOff == null || onOff.length != 4) onOff = new boolean[4];
        this.onOff = onOff;
    }

    protected int space;
    protected boolean onOff[];//ltrb

    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        outRect.left = onOff[0] ? space : 0;
        outRect.top = onOff[1] ? space : 0;
        outRect.right = onOff[2] ? space : 0;
        outRect.bottom = onOff[3] ? space : 0;
    }
}
